﻿using System;
using System.Diagnostics.Contracts;
using System.IO;

namespace OpenWaves.ImageTransformations.Web
{
    [ContractClass(typeof(ConcurrentFileStoreContract))]
    public interface IConcurrentFileStore
    {
        Url GetOrCreateFileUrl(string fileName, TimeSpan waitTimeout, Action<Stream> fileCreatedCallback);
    }

    [ContractClassFor(typeof(IConcurrentFileStore))]
    abstract class ConcurrentFileStoreContract : IConcurrentFileStore
    {
        public Url GetOrCreateFileUrl(string fileName, TimeSpan waitTimeout, Action<Stream> fileCreatedCallback)
        {
            Contract.Requires<ArgumentNullException>(String.IsNullOrEmpty(fileName) == false);
            Contract.Requires<ArgumentOutOfRangeException>(waitTimeout >= TimeSpan.Zero);
            Contract.Requires<ArgumentNullException>(fileCreatedCallback != null);
            Contract.Ensures(Contract.Result<Url>() != null);

            throw new NotImplementedException();
        }
    }
}